import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'
import Book from '../views/Book.vue'
import User from "../views/User";

const routes = [
  {
    //path"/" 和 component，就是一组映射页面的展示
    path: '/',
    name: 'layout',
    component: Layout,
    redirect:"/user",
    children:[
      {
        path: 'user',
        name: 'User',
        component: () => import("@/views/User"),
      },
      {
        path: '/person',
        name: 'Person',
        component: () => import('@/views/Person')
      },
      {
        path: '/book',
        name: 'Book',
        component: () => import('@/views/Book')
      },
      {
        path: '/news',
        name: 'News',
        component: () => import('../views/News')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
